package clue

import (
	"git.mycaigou.com/gfyx/micro-gfyx-api/http_server/controller"
	"git.mycaigou.com/gfyx/micro-gfyx-api/infrastructure/common/errcode"
	"git.mycaigou.com/gfyx/micro-gfyx-api/infrastructure/dto/clue"
	"git.mycaigou.com/gfyx/micro-gfyx-api/infrastructure/utils"
	clue2 "git.mycaigou.com/gfyx/micro-gfyx-api/service/clue"
	"git.myscrm.cn/golang/stark/v4"
	"github.com/gin-gonic/gin"
)

/**
 * @Author: xiuliu
 * @Description:客户监控
 * @File:  customer_monitor_controller
 * @Version: 1.0.0
 * @Date: 2023/12/14 10:29
 */

type CustomerMonitorController struct {
	controller.BaseController
	customerMonitorService clue2.CustomerMonitorServiceIface
}

func (c *CustomerMonitorController) RegisterRouter(g *gin.RouterGroup) {
	// 批量添加客户池
	g.POST("get-customer-monitor-list", c.getCustomerMonitorList)
}

func NewCustomerMonitorController(customerMonitorService clue2.CustomerMonitorServiceIface) *CustomerMonitorController {
	return &CustomerMonitorController{
		customerMonitorService: customerMonitorService,
	}
}

func (c *CustomerMonitorController) getCustomerMonitorList(ctx *gin.Context) {
	var request clue.GetCustomerMonitorRequest
	if err := ctx.ShouldBind(&request); err != nil {
		c.Fail(ctx, errcode.COMMON_PARAMS_ERROR, utils.GetValidateErr(request, err))
		return
	}

	resp, err := c.customerMonitorService.GetCustomerMonitorList(ctx, &request)
	if err != nil {
		stark.Logger.Errorf(ctx, "getCustomerMonitorList errors:%+v", err)
		c.Fail(ctx, errcode.COMMON_ERROR, err.Error())
		return
	}

	c.Success(ctx, resp)
}
